package com.augurit.gzcgwsp.exchangeOtherData;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.TimerTask;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.augurit.gzcgwsp.exchangeOtherData.service.IInteriornetDataService;
import com.augurit.gzcgwsp.wfex.common.util.WfUtilsEX;

/**
 * 定时发送邮件类
 * @author Administrator
 *
 */
public class InteriornetTimer extends TimerTask{ 
	private static final Logger logger=Logger.getLogger(InteriornetTimer.class);
	@Autowired
	private IInteriornetDataService interiornetDataService;

	@Override
	public void run() {
		try {
			Locale locale = Locale.getDefault(); 
			InetAddress addr = null;
			addr = InetAddress.getLocalHost();
			String ip=addr.getHostAddress().toString();//获得本机IP
			logger.info("--ip--"+ip); 
			if(!ip.contains("192.168.")){//在城管委以192.168开头的地址不执行
				exchageDbYbBj();		
			}
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
	
	/**
	 * 与内门户交换数据
	 */
	public void exchageDbYbBj(){
		logger.info("进来待办已办------------------------");
		logger.info("与内门户交换数据开始..........");
		try {
			interiornetDataService.updateDbdata();
			//插入待办已办办结
			interiornetDataService.insertDbData();
			interiornetDataService.insertYbData();
			interiornetDataService.insertBjData();
			interiornetDataService.createDbDoc();//待办
			interiornetDataService.createYbDoc();//已办
			interiornetDataService.createBjDoc();//办结
			logger.info("待办已办------------------------");
		} catch (RuntimeException e) {
			logger.error("与内门户交换数据开始.........."+e);
		}
		
		logger.info("与内门户交换数据结束..........");
	}

}
